package example.dawangba.com.z09315222_finalandroidhomework;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import java.util.Timer;
import java.util.TimerTask;

public class SplashActivity extends Activity {

    Animation animation;
    ImageView img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        img= (ImageView) findViewById(R.id.welcome);
        animation = new AlphaAnimation(0,1);
        animation.setDuration(5000);
        img.startAnimation(animation);
        Timer timer=new Timer();
        TimerTask task=new TimerTask() {
            @Override
            public void run() {
                Thread t=new Thread(){
                    @Override
                    public void run() {
                        super.run();
                        Intent intent=new Intent(SplashActivity.this,TabHostDemo.class);
                        startActivity(intent);
                        //防止点击返回键之后停止在登录欢迎界面,因此跳转完成后直接结束该Activity
                        finish();
                    }
                };
                runOnUiThread(t);
            }
        };
        timer.schedule(task,2000);
    }
}
